<?php
namespace  Admin\Controller;
use Think\Controller;
class CasesController extends IndexController{
    public function lists(){
        $this->display();
    }

    public function get_lists(){
        $UserInfo=D('Userinfo_diagnosis');

        if(I("request.iDisplayStart")==''){
            $start=0;
        }else{
            $start=I("request.iDisplayStart");
        }
        if(I("request.sSearch")!=''){
            $where['truename'] = array('like','%'.I("request.sSearch").'%');;
        }else{
            $where='';
        }

        $result= $UserInfo->where($where)->limit($start,I("request.iDisplayLength"))->select();
        if($result){

            $ret = array(
                "sEcho" => intval($_GET['sEcho']),
                "iTotalRecords" => $start,
                "iTotalDisplayRecords" =>$UserInfo->count(),
                "aaData" => $result
            );


            echo json_encode($ret);exit;

        }else{
            echo json_encode(0);exit;
        }
    }

    public function del(){
        $id= I("request.id");
        if($id!=""){
            $UserInfo=D('Userinfo_diagnosis');
            $map['id']=$id;
            $image=$UserInfo->where($map)->field('imgone,leftimg,rightimg')->find();
           foreach($image as $key=>$value){
               if($value!=""){
                   unlink("./image_binli/".$value);
               }
           }
            $result=$UserInfo->where($map)->delete();
            if($result){
                echo json_encode(1);exit;
            }
        }
    }
}